<template>
    <div class="temp">
       <div class="newsTitle">
           <h3 v-text="news.title"></h3>
           <p>{{news.add_time | datefmt('YYYY-MM-DD')}} {{news.click}}次浏览</p>
       </div>
       <div class="newsContent" v-html="news.content"></div>
        <comment :artid="newsid"></comment>
    </div>
</template>

<script>
    import {Toast} from 'mint-ui';
    import common from "../../kits/common.js";
    import comment from '../subcom/comment.vue';//引入评论模块
    export default {
        data() {
            return {
                newsid:0,
                news:{}
            }
        },
        created() {
            this.newsid = this.$route.params.newsid;
            this.getNews();
        },
        methods:{
            getNews() {
                const url = common.apidomain+"/api/getnew/" + this.newsid;
                this.$http.get(url).then((response)=>{
                    let body = response.body;
                    if(body.status != 0){
                        Toast({
                            message: body.message,
                            position: 'bottom',
                            duration: 5000
                        });
                        return;
                    }
                    this.news = body.message[0];
                });
            }
        },
        components:{
            comment
        }
    }
</script>

<style scoped>
    .newsContent,.newsTitle {
        padding: 10px;
    }
    .newsTitle h3 {
        color: #26d0ff;
    }
    .newsTitle p {
        color: rgba(0,0,0,.5);
        font-size: 14px;
    }
</style>